﻿// JS
//Add by still_wind 2009,1,4
//获取元素的纵坐标，包括绝对定位

var DomHelper = function(){};
DomHelper.getTop = function (e)
{ 
var offset=0; 
if(e.offsetParent!=null && e.style.position!='absolute')
  {
   offset += e.offsetTop;
   offset+=DomHelper.getTop(e.offsetParent); 
  }
return offset; 
};
//获取元素的横坐标，包括绝对定位

DomHelper.getLeft = function (e)
{ 
var offset=0; 
if(e.offsetParent!=null && e.style.position!='absolute')
 {
  offset += e.offsetLeft;
  offset+=DomHelper.getLeft(e.offsetParent); 
 }
return offset; 
};
//获取元素的横坐标，包括绝对定位

DomHelper.getAbsTop = function (e)
{ 
var offset=0; 
if(e.offsetParent!=null)
 {
  offset += (e.offsetTop-e.scrollTop);
  offset+=DomHelper.getAbsTop(e.offsetParent); 
 }
return offset; 
};

//获取元素的横坐标，包括绝对定位

DomHelper.getAbsLeft = function (e)
{ 
var offset=0; 
if(e.offsetParent!=null)
 {
  offset += e.offsetLeft;
  offset+=DomHelper.getAbsLeft(e.offsetParent); 
 }
return offset; 
};

DomHelper.getMousePosition = function()
 {
   var postion = {x:0, y:0};
  postion.x = event.clientX;
  postion.y = event.clientY;
  return postion;
 };
DomHelper.getPrevBrother = function(elmt)
 {
   var par = elmt.parentNode;
   if(par)
   {
       var arr = [];
       for(var i=0; i<par.childNodes.length; i++)
        {
          if(par.childNodes[i].tagName)
           {
            if(par.childNodes[i]==elmt)
             {
               if(arr.length>0)
                {
                  return arr[arr.length-1];
                }
               else
                {
                  return null;
                }
             }
            else
             {
               arr[arr.length] = par.childNodes[i];
             }
           }
        }
    }
   else
    {
      return null;
    }
 };
DomHelper.getNextBrother = function(elmt)
 {
   var par = elmt.parentNode;
   if(par)
   {
       var arr = [];
       for(var i=par.childNodes.length-1; i<par.childNodes.length; i--)
        {
          if(par.childNodes[i].tagName)
           {
            if(par.childNodes[i]==elmt)
             {
               if(arr.length>0)
                {
                  return arr[arr.length-1];
                }
               else
                {
                  return null;
                }
             }
            else
             {
               arr[arr.length] = par.childNodes[i];
             }
           }
        }
    }
   else
    {
      return null;
    }
 };
DomHelper.HideElement = function(e)
 {
   if(document.getElementById(e))
    {
      e=document.getElementById(e);
    }
   e.style.display = 'none';
 };
DomHelper.ClickElement = function(elmtid)
 {
   document.getElementById(elmtid).click();
 };